package com.hs.service.impl;

import com.hs.entity.Course;
import com.hs.mapper.CourseMapper;
import com.hs.mapper.SequenceMapper;
import com.hs.service.CourseService;
import com.hs.service.SequenceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CourseServiceImpl implements CourseService {

    @Autowired
    private CourseMapper courseMapper;

    @Autowired
    private SequenceService sequenceService;

    //查询课程信息列表
    @Override
    public List<Course> findCourseList(String searchKey) {
        return courseMapper.findCourseList(searchKey);
    }

    @Override
    public Integer addCourse(Course course) {
        String code="DWA";
        code = sequenceService.courseCode("cou_seq");
        System.out.println(code);
        course.setCode(code);
        return courseMapper.addCourse(course);
    }

    @Override
    public int delCourseById(Integer id) {
        return courseMapper.deleteByPrimaryKey(id);
    }

    @Override
    public List<Course> queryCourseList() {
        return courseMapper.queryCourseList();
    }
}
